package com.starmark.gateway.auth.security.utils;


import org.springframework.util.AntPathMatcher;

/**
 * @author starmark
 * @date 20-2-14  下午5:10
 */
public final class RequestHelper {








    /**
     * @param url 请求URL
     * @return 处理后的Url
     */
    public static String handleEndUrl(String url) {

        if (!url.endsWith("**")) {
            return url + "**";
        }
        return url;
    }

    /**
     * 判断是否URL匹配
     *
     * @param urlPattern  url正则表达式
     * @param url         请求url
     * @param projectCode 工程编码
     * @return 是否匹配
     */
    public static boolean isMatchUrl(String urlPattern, String url) {
        AntPathMatcher antPathMatcher = new AntPathMatcher();
        return antPathMatcher.match(handleEndUrl(urlPattern), url);

    }

}
